<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./adminTemplate.xhtml">

            <ui:define name="title">
                List Company
            </ui:define>

            <ui:define name="contain">
                <h:form id="form">
                    <h2 class="ico_mug">List Company</h2>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true"></p:messages>
                    <p:dataTable id="table-item" var="com" value="#{companyController.listCom}" 
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="10,15,20" paginator="true" rows="10">  
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                ID 
                            </f:facet>  
                            <h:outputText value="#{com.id}" />  
                        </p:column>  
                        <p:column>  
                            <f:facet name="header">  
                                Name 
                            </f:facet>  
                            <h:outputText value="#{com.name}" />  
                        </p:column>                              
                        <p:column>  
                            <f:facet name="header">  
                                Contact
                            </f:facet>  
                            <h:outputText value="#{com.contactPerson}" />  
                        </p:column>
                        <p:column>  
                            <f:facet name="header">  
                                Designation  
                            </f:facet>  
                            <h:outputText value="#{com.designation}"/>
                        </p:column>
                        <p:column>  
                            <f:facet name="header">  
                                Address  
                            </f:facet>  
                            <h:outputText value="#{com.address}"/>
                        </p:column>                       
                        <p:column>  
                            <f:facet name="header">  
                                Telephone 
                            </f:facet>  
                            <h:outputText value="#{com.telephone}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Member Type  
                            </f:facet>  
                            <h:outputText value="#{com.memberType}"/>
                        </p:column>
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                Status  
                            </f:facet>  
                            <img src="img/#{com.status}.png" border="0" /> 
                        </p:column>
                        <p:column style="text-align: center;width: 60px">  
                            <f:facet name="header">  
                                Action  
                            </f:facet>  
                            <h:commandLink action="detailCompany">
                                <f:setPropertyActionListener value="#{com}" target="#{companyBean.company}" />
                                <img src="img/detail.png" alt="edit"/>
                            </h:commandLink>
                            <p:commandLink action="#{companyController.selectedID(com.id)}" oncomplete="confirmation.show()">
                                <img src="img/delete.png" alt="delete"/>
                            </p:commandLink>
                            <h:commandLink actionListener="#{companyBean.edit(com)}">
                                <img src="img/edit.png" alt="edit"/>
                            </h:commandLink>
                        </p:column> 
                    </p:dataTable>
                    <p:confirmDialog id="confirmation" message="Are you sure to delete this Company?"  
                                     header="Delete Company" severity="alert" widgetVar="confirmation" > 
                        <p:commandButton value="Yes Sure" update=":form:table-item" oncomplete="confirmation.hide()"  
                                         actionListener="#{companyController.deleteCompany()}" />  
                        <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   
                    </p:confirmDialog>

                    <p:fieldset legend="Edit Information">
                        <table cellpadding="5">
                            <tbody>
                                <tr>
                                    <td style="width: 80px"><h:outputLabel value="ID:"/></td>
                                    <td style="width: 200px"><p:inputText value="#{companyBean.id}"/></td>
                                    <td style="width: 80px"><h:outputLabel value="Name:"/></td>
                                    <td><p:inputText id="name" value="#{companyBean.name}"/> </td>
                                </tr>
                                <tr>
                                    <td> <h:outputLabel value="Contact Person:"/></td>
                                    <td><p:inputText id="contact" value="#{companyBean.contactPerson}"/></td>
                                    <td><h:outputLabel value="Designation:"/></td>
                                    <td><p:inputText id="designation" value="#{companyBean.designation}"/></td>

                                </tr>
                                <tr>
                                    <td><h:outputLabel value="Address:"/></td>
                                    <td><p:inputText id="address" value="#{companyBean.address}"/>   </td>
                                    <td><h:outputLabel value="Mobile:"/></td>
                                    <td><p:inputText id="mobile" value="#{companyBean.mobile}"/></td>

                                </tr>

                                <tr>
                                    <td><h:outputLabel value="Telephone:"/></td>
                                    <td><p:inputText id="telephone" value="#{companyBean.telephone}"/></td> 
                                    <td><h:outputLabel value="Fax"/></td>
                                    <td><p:inputText id="fax" value="#{companyBean.fax}"/></td>
                                </tr>
                                <tr>
                                    <td><h:outputLabel value="Status"/></td>
                                    <td><p:selectOneRadio value="#{companyBean.status}" id="se" label="status">  
                                            <f:selectItem itemLabel="Accept" itemValue="true" />  
                                            <f:selectItem itemLabel="Deny" itemValue="false" />                                       
                                        </p:selectOneRadio></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td><p:commandButton ajax="false" value="Update" actionListener="#{companyController.editSubmit()}"/>
                                    </td>
                                </tr>                                
                            </tbody>
                        </table>
                    </p:fieldset>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
